home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / smaltalk / manchest.lha / MANCHESTER / manchester / 4.1 / interactors / Interactors-Support.st < prev    next >
Text File  |  1993-07-24  |  4KB  |  129 lines

  1. Object subclass: #IdentityWrapper
  2.     instanceVariableNames: 'value '
  3.     classVariableNames: ''
  4.     poolDictionaries: ''
  5.     category: 'Interactors-Support'!
  6.  
  7.  
  8. !IdentityWrapper methodsFor: 'acessing'!
  9.  
  10. value
  11.     ^value! !
  12.  
  13. !IdentityWrapper methodsFor: 'private'!
  14.  
  15. setValue: aValue
  16.     value := aValue! !
  17. "-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- "!
  18.  
  19. IdentityWrapper class
  20.     instanceVariableNames: ''!
  21.  
  22.  
  23. !IdentityWrapper class methodsFor: 'instance creation'!
  24.  
  25. on: aValue
  26.     ^super new setValue: aValue! !
  27.  
  28. TextItemEditor subclass: #TextFieldEditor
  29.     instanceVariableNames: ''
  30.     classVariableNames: ''
  31.     poolDictionaries: ''
  32.     category: 'Interactors-Support'!
  33.  
  34.  
  35. !TextFieldEditor methodsFor: 'initialize-release'!
  36.  
  37. initialize
  38.     super initialize.
  39.     self crBlock: [self view container accepted]! !
  40.  
  41. !TextFieldEditor methodsFor: 'control defaults'!
  42.  
  43. isControlActive
  44.     ^self sensor blueButtonPressed not
  45.         and: [view bounds containsPoint: self sensor cursorPoint]! !
  46.  
  47. !TextFieldEditor methodsFor: 'editing'!
  48.  
  49. replaceFrom: start to: stop with: aText
  50.     "Replace the receiver's text starting at position start, stopping at stop, 
  51.     by the characters in aText."
  52.  
  53.  
  54.     |  changeInfo startLine affectedLines lineDelta |
  55.     self textHasChanged: true.
  56.     self text size = 0
  57.         ifTrue: [self paragraph replaceFrom: start to: stop with: aText.
  58.                 view invalidate]
  59.         ifFalse: [| lineIndex |
  60.                 lineIndex := self paragraph lineIndexOfCharacterIndex: start. 
  61.                 changeInfo :=self paragraph replaceFrom: start to: stop with: aText.
  62.                 startLine := changeInfo at: 1.
  63.                 affectedLines := changeInfo at: 3.
  64.                 lineDelta := changeInfo at: 2.
  65.                 (lineDelta = 0 and:
  66.                         [affectedLines = 1 and:
  67.                         [view textStyle alignment = LeftFlush and: 
  68.                         [view startBlock top = (view topAtLineIndex: startLine)]]])
  69.                     ifTrue: [ | sb rect lineLast gc |
  70.                             sb := view startBlock.
  71.                             gc := view graphicsContext.
  72.                             (gc clippingBounds containsPoint: sb origin)
  73.                                 ifFalse:    [^self].
  74.                             lineLast := (self paragraph lineAt: lineIndex) last.
  75.                             (self text string at: lineLast) == Character cr
  76.                                 ifTrue: [lineLast := lineLast -1].
  77.                             rect := Rectangle origin: sb left@sb top 
  78.                                             corner: view clippingBox right@sb bottom.
  79.                             (start < lineLast or: [(stop < start) not  or: [aText size = 0]])
  80.                                 ifTrue: [gc paint: view backgroundColor.
  81.                                         gc displayRectangle: rect].
  82.                             gc paint: view foregroundColor.
  83.                             self paragraph displayFromCharacter: start to: lineLast startX: rect left
  84.                                 forTranslation: view displayOrigin on: gc]
  85.                     ifFalse: [view
  86.                                 redisplayAfterReplacementAt: startLine
  87.                                 affectedLines: affectedLines
  88.                                 lineDelta: lineDelta]].! !
  89.  
  90. ComposedTextView subclass: #TextFieldView
  91.     instanceVariableNames: ''
  92.     classVariableNames: ''
  93.     poolDictionaries: ''
  94.     category: 'Interactors-Support'!
  95.  
  96.  
  97. !TextFieldView methodsFor: 'initialize-release'!
  98.  
  99. initialDisplayContents
  100.     ^'' asComposedText! !
  101.  
  102. !TextFieldView methodsFor: 'controller access'!
  103.  
  104. defaultControllerClass
  105.     "Answer the default controller class for the receiver."
  106.  
  107.     ^TextFieldEditor! !
  108.  
  109. !TextFieldView methodsFor: 'displaying'!
  110.  
  111. displayOn: aGC
  112.     aGC clippingRectangle: nil.
  113.     super displayOn: aGC.
  114.     controller trackMouseSelection        "cheap trick to cause insertion point to be displayed"!
  115.  
  116. invalidate
  117.     ^container render! !
  118. "-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- "!
  119.  
  120. TextFieldView class
  121.     instanceVariableNames: ''!
  122.  
  123.  
  124. !TextFieldView class methodsFor: 'instance creation'!
  125.  
  126. on: aStringOrText
  127.  
  128.     ^self new editText: aStringOrText asText! !
  129.